define(['modules/fetch'],function(fetch){

    function loadSidebarData(param={}){
        var pn = param.pn ? param.pn : 0;
        var ps = param.ps ? param.ps : 20;
        var nodeId = param.node_id;
        if(isNaN(parseInt(nodeId))){
            console.log("loadSidebarData param error");
            return false;
        }
        fetch('listChaptersByNodeId', { pn: 0, ps: 20},
            function (result) {
                if(0 == result.errno ){
                    vueSidebarData.listbarList = result.data;
                    console.log(vueSidebarData);
                }
            },
            function(data) {
                console.log("ajax faild");
            }
        );
    }
    var vueSidebarData = {
        listbarList:[],
    };
    new Vue({
        el: "#sidebar",
        data: vueSidebarData,
        methods:{
            sidebarItemClick: function(index,item, currentId){
                if(currentId == item.story_id){
                    return false;
                }
                location.href="/story/readStory?id=" + parseInt(item.story_id);
                console.log(index,item);
            }
        }
    });
    return loadSidebarData;
});